home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / INCLUDE / VGAJOYST.{4C < prev    next >
Text File  |  1999-09-17  |  2KB  |  69 lines

  1. #ifndef VGAJOYSTICK_H
  2. #define VGAJOYSTICK_H
  3. /* Joystick interface modeled after svgalibs keyboard and mouse interfaces 
  4.  * Copyright 1998 Daniel Engstr÷m <daniel.engstrom@riksnett.no> 
  5.  * Partly based on code from 
  6.  * joystick-0.7.3 Copyright (C) 1992, 1993 Author C. Smith
  7.  * and 
  8.  * joystick-1.0.6 Copyright (C) 1997 Vojtech Pavlik 
  9.  *
  10.  * Extension and modifications. Multiple joystick support, VC switching,
  11.  * etc. Michael Weller <eowmob@exp-math.uni-essen.de>.
  12.  */
  13.  
  14. /* event for joystick handlers */
  15. #define JOY_EVENTBUTTONDOWN 1
  16. #define JOY_EVENTBUTTONUP   2
  17. #define JOY_EVENTAXIS       3
  18.  
  19. /* file is a struct FILE to output calibration instructions to,
  20.  * set to NULL to skip calibration 
  21.  */
  22.  
  23. typedef void (*__joystick_output) (const char *msg);
  24.  
  25. int joystick_init(int joydev, __joystick_output jo);
  26.  
  27. /* This is guaranteed not to collide with any user definition */
  28. #define JOY_CALIB_STDOUT ((__joystick_output)(void *)joystick_init)
  29.  
  30. void joystick_close(int joydev);
  31.  
  32. /* polls the joystick and calls the eventhandler */
  33. int joystick_update(void);
  34.  
  35. typedef void (*__joystick_handler) (int event, int number, char value, int joydev); 
  36.  /* event - event type; see above
  37.  * number - the axis or button number for this event 0=x axis or button 1, etc.
  38.  * value - value for axis events -128 - 0 - +127
  39.  */
  40. void joystick_sethandler(int joydev, __joystick_handler jh);
  41. void joystick_setdefaulthandler(int joydev);
  42.  
  43. char joystick_getnumaxes(int joydev);
  44. char joystick_getnumbuttons(int joydev);
  45.  
  46. /* querys the default handler if used */
  47. char joystick_getaxis(int joydev, int a);
  48. char joystick_getbutton(int joydev, int b);
  49.  
  50. #define joystick_button1(i) joystick_getbutton(i, 0)
  51. #define joystick_button2(i) joystick_getbutton(i, 1)
  52. #define joystick_button3(i) joystick_getbutton(i, 2)
  53. #define joystick_button4(i) joystick_getbutton(i, 3)
  54.  
  55. #define joystick_getb1() joystick_getbutton(0, 0)
  56. #define joystick_getb2() joystick_getbutton(0, 1)
  57. #define joystick_getb3() joystick_getbutton(0, 2)
  58. #define joystick_getb4() joystick_getbutton(0, 3)
  59.  
  60. #define joystick_x(i) joystick_getaxis(i, 0)
  61. #define joystick_y(i) joystick_getaxis(i, 1)
  62. #define joystick_z(i) joystick_getaxis(i, 2)
  63.  
  64. #define joystick_getx() joystick_getaxis(0, 0)
  65. #define joystick_gety() joystick_getaxis(0, 1)
  66. #define joystick_getz() joystick_getaxis(0, 2)
  67.  
  68. #endif
  69.